// @ts-ignore
/* eslint-disable */
import { request } from '@umijs/max';

export async function getCaptcha() {
  return request<API.ResponseResult>('/api/xmbz-auth/captcha', {
    method: 'GET',
  });
}

export async function login(body: API.LoginParams, options?: { [key: string]: any }) {
  return request<API.ResponseResult>('/api/xmbz-auth/token', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Captcha-Key': body.key || '',
      'Captcha-Code': body.code || '',
    },
    params: {
      grantType: 'password',
      account: body.account,
      password: body.password,
      type: body.type,
      code: body.code,
    },
    ...(options || {}),
  });
}

export async function getMenu() {
  return request<API.ResponseResult>('/api/xmbz-system/menu/routes', {
    method: 'GET',
  });
}